home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _7FAF6B459AEE43DCB7CE660127AC7C85 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.2 KB  |  35 lines

  1.       #include "../CGVPMacro.csi"
  2.  
  3.       MainInput { uniform sampler2D glossMap : texunit0,
  4.                   uniform sampler2D bumpMap : texunit1,
  5.                   uniform samplerCUBE normCubeMapHA : texunit2,
  6.                   uniform sampler2D attenMap : texunit3,
  7.                   uniform float4 Specular }
  8.       DeclarationsScript
  9.       {
  10.         OUT_T0_T1_T2_T3_C0
  11.         FOUT
  12.       }
  13.       CoreScript
  14.       {
  15.         // load the decal
  16.         float4 glossColor = tex2D(glossMap, IN.Tex0.xy);
  17.         // load the bump normal
  18.         float4 bumpNormal = 2*(tex2D(bumpMap, IN.Tex1.xy)-0.5);
  19.         float atten = saturate((2*(IN.Color.b-0.5)) * -(2*(IN.Color.b-0.5)) + (1-tex2D(attenMap, IN.Tex3.xy).b));
  20.  
  21.         // Half angle vector from normalization cube-map
  22.         float4 hVec = 2*(texCUBE(normCubeMapHA, IN.Tex2.xyz)-0.5);
  23.         
  24.         float NdotH = saturate(dot(hVec.xyz, bumpNormal.xyz));
  25.         float  specVal = saturate((NdotH - 0.75)*4);
  26.         specVal = specVal * specVal;
  27.         float3 spec = (specVal * Specular.xyz * glossColor.xyz * atten) * 2;
  28.  
  29.         // finally add them all together
  30.         OUT.Color.xyz = spec;
  31.         OUT.Color.w = Specular.w * glossColor.w;
  32.       }
  33.  
  34.  
  35.